#include <iostream>
#include <string>
#include <sstream>
#include <utility>
#include <algorithm>
#include <windows.h>

using namespace std;

string convert(int32_t num);

int main()
{
    SetConsoleOutputCP(CP_UTF8);

    while (true)
    {
        int32_t num(0);
        cout << "> ";
        cin >> num;
        if (!cin)
        {
            cin.clear();
            cin.ignore(256, '\n');
            continue;
        }

        cout << convert(num) << endl;
    }

    return 0;
}

string convert(int32_t num)
{
    // 一级单位
    string units1[] = {
        "",
        "十",
        "百",
        "千"
    };

    // 二级单位
    string units2[] = {
        "万",
        "亿"
    };

    // 数字
    string numbers[] = {
        "零",
        "一",
        "二",
        "三",
        "四",
        "五",
        "六",
        "七",
        "八",
        "九"
    };

    string retStr;

    ostringstream sstream;
    sstream << fixed << (num < 0 ? -num : num);

    string str = sstream.str();
    reverse(str.begin(), str.end());

    bool needZero = false;
    bool hasZero = false;
    for (int i=0; i<str.size(); ++i)
    {
        string number = numbers[str[i] - '0'];
        string unit = units1[i % 4];

        if (i == str.size() - 1 && number == "一" && unit == "十")
            number = "";

        if (i % 4 == 0 && i != 0)
        {
            unit = units2[i / 4 - 1];
            needZero = false;
            hasZero = false;

            if (number == "零")
                number = "";
            else
                needZero = true;
        }
        else if (number == "零")
        {
            if (needZero)
            {
                if (hasZero)
                    number = "";
                else
                    hasZero = true;
            }
            else {
                number = "";
            }

            unit = "";
        }
        else {
            needZero = true;
            hasZero = false;
        }

        retStr = number + unit + retStr;
    }

    if (num < 0)
        retStr = "负" + retStr;

    return retStr;
}
